package top.yxqz.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Mr.余
 * @date 2022/11/7
 * @package top.yxqz.servlet
 */
    public class ServletDemo3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("你请求了servlet了");
        String method = request.getMethod();//获取请求的方法名称
        if ("GET".equals(method)) System.out.println("get方法请求的");
        if ("POST".equals(method)) System.out.println("post方法请求的");

    }
}
